package main

import (
	"fmt"
	"strconv"
	"time"
)

//func main() {
//	done := make(chan struct{})
//	for i := 0; i < 10; i++ {
//		go handle(done, i)
//	}
//	for {
//		done <- struct{}{}
//	}
//
//	time.Sleep(10 * time.Second)
//}

func handle(done <-chan struct{}, i int) {
	for {
		time.Sleep(1 * time.Second)
		select {
		case <-done:
			fmt.Println("handle " + strconv.Itoa(i) + "running")
		default:
			fmt.Println("handle " + strconv.Itoa(i) + "waiting")
		}
	}

}
